<template>
  <div>
    <!--卡片-->
    <el-tabs v-model="activeName" type="border-card">
      <el-tab-pane v-for="item in data" :key="item.name" :lazy="true" :label="item.name" :name="item.name">
        <Java :value="item.content" :height="height" />
      </el-tab-pane>
    </el-tabs>

  </div>
</template>

<script>
import Java from '@/components/JavaEdit/index'
import { preview } from '@/api/sys-tools/generator'

export default {
  name: 'Preview',
  components: { Java },
  data() {
    return {
      data: null, height: '', activeName: 'req',
      entity: '',
      req: '',
      controller: '',
      service: '',
      serviceImpl: '',
      mapper: '',
      mapperXml: '',
      api: '',
      index: ''
    }
  },
  created() {
    // 给代码文本框传自定义的高度
    this.height = document.documentElement.clientHeight - 180 + 'px'
    // 初始化列表
    this.initList()
  },

  methods: {
    // 预览按钮
    previewBtn() {
      this.addDialogVisible = true
    },

    // 配置按钮
    cfgBtn() {
      this.addDialogVisible = true
    },

    // 生成按钮
    createBtn() {
      this.addDialogVisible = true
    },

    // 下载按钮
    downloadBtn() {
      this.addDialogVisible = true
    },

    // 初始化数据
    initList() {
      preview(this.$route.params.tableName).then(res => {
        this.data = res.data
      })
    }

  }
}
</script>

<style scoped>
</style>
